package com.ishanshan.gateway.util;

import com.netflix.zuul.context.RequestContext;

/**
 * Created by WANGHJ on 2019-01-24.
 */
public  class SysNameUtil {

    public static void saveSysName(){

        RequestContext requestContext =  RequestContext.getCurrentContext();
        String url = requestContext.getRequest().getRequestURI();
        if(url.startsWith("/api/")){
            url = url.replace("/api/","");
            int i = url.indexOf("/");
            String sysName = url.substring(0,i);
            requestContext.set("sysName",sysName);
        }
    }

    public static String getSysName(){
        RequestContext requestContext =  RequestContext.getCurrentContext();
        return requestContext.get("sysName") == null?"":requestContext.get("sysName").toString();
    }

}
